/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	hey 
 * 
 * <p>描   述  :   GovernSpeedController.java for com.pengtu.gsj.controller.lzgl    </p>
 * 
 * <p>最后修改 : $: Sep 13, 2017-9:40:55 AM v 1.0.0	 hey   $ </p>
 * 
*/

package com.pengtu.gsj.controller.lzgl;

import javax.servlet.http.HttpServletRequest;


import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.lzgl.GovernSpeed;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.lzgl.GovernSpeedService;
import com.pengtu.gsj.utils.web.SpringMvcUtils;

/**
 * 
 * GovernSpeedController
 * 
 * Sep 13, 2017 9:40:55 AM
 * 
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("governSpeed")
public class GovernSpeedController extends DefaultBaseController {
	@Autowired
	private GovernSpeedService governSpeedService;
	
	
	
	/**
	 * 加载
	 * @param id
	 * @return
	 */
	@ModelAttribute
	public GovernSpeed load(String id){
		GovernSpeed governSpeed;
		if(StringUtils.isNotEmpty(id)){
			governSpeed = governSpeedService.getGovernSpeedById(id);
		}else{
			governSpeed = new GovernSpeed();
		}
		return governSpeed;
	}
	
	
	/**
	 * 页面跳转
	 * @return
	 */
	@RequestMapping("listInfo")
	@Token(save = true)
	public String showLisfInfo() {
		return "lzgl/governSpeed_list";
	}
	
	
	/**
	 * 
	 * getRoadMaterialList:
	 * 适用:
	 * @param page
	 * @param request
	 * @return 
	 * @exception 
	 * @since  1.0.0
	 */
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	@ResponseBody
	public Page<GovernSpeed> getRoadMaterialList(Page<GovernSpeed> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("testYear");
			page.setOrder(Page.ASC);
		}
		page = governSpeedService.findGovernSpeed(page,queryFilter);
		return page;
	}
	
	/**
	 * 保存
	 * @param roadMaterial
	 * @return
	 */
	@RequestMapping(value = "save", method=RequestMethod.POST)
	@ResponseBody
	@Token(remove = true)
	public boolean saveGovernSpeed(@ModelAttribute GovernSpeed governSpeed){
		governSpeedService.saveGovernSpeed(governSpeed);
		return true;
	}
	
	
	/**
	 * 加载数据
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="show")
	@ResponseBody                                                     
	public GovernSpeed showGovernSpeed (@ModelAttribute GovernSpeed governSpeed){
		return governSpeed;
	}
	
	/**
	 * 删除
	 * @param infoManagement
	 * @return
	 */
	@RequestMapping(value="delete")
	@ResponseBody
	public boolean delateInfoManagement(@ModelAttribute GovernSpeed governSpeed){
		governSpeedService.delateGovernSpeed(governSpeed);
		return true;
	}
	
	
	/**
	 * 
	 * checkYearStation:
	 * 适用:新增和修改 治超执法记录 时，ajax判断 年份+检测站名称 在数据库中是否已经存在
	 * @return  返回true或false  json数据
	 * @exception 
	 * @since  1.0.0
	 */
	@ResponseBody
	@RequestMapping(value = "checkYearStation", produces = "application/json; charset=utf-8")
	public Boolean checkYearStation() {
		String testYear = SpringMvcUtils.getParameter("testYear");
		String stationName = SpringMvcUtils.getParameter("stationName");
		String id = SpringMvcUtils.getParameter("id");
		return governSpeedService.checkIsSame(testYear, stationName, id);
	}
}
